/********************************************************
 Name          : main.c
 Author        : Nipun Batra
 Copyright     : Apache 2
 Description   : Toggle color of bicolor LED when Push Button PB0 is pressed
 **********************************************************/

// Include Files 

#include "gpio.h"


int main(void) {

	int state,enable,disable,color,en,di;
	en=1;
	di=0;
	color=0;//Red
	//color=1;Green



	
	while(1)
	{
		AVR32_GPIO.port[1].gpers = 2 <<24;
		state=(AVR32_GPIO.port[2].pvr >> 24) & 0x01;
		if(state==0)
				{
					color=(color+1)%2;//Toggle color
					en=(en+1)%2;
					di=(di+1)%2;
					enable=19+en;//Toggle enable b/w 19 and 20
					disable=19+di;//Toggle disable b/w 20 and 19

				}
		AVR32_GPIO.port[1].gpers = 1 <<disable;
		AVR32_GPIO.port[1].oders = 1 <<disable;
		AVR32_GPIO.port[1].ovrs = 1 <<disable;
		AVR32_GPIO.port[1].gpers = 1 <<enable;
		AVR32_GPIO.port[1].oders = 1 <<enable;
		AVR32_GPIO.port[1].ovrc = 1 <<enable;
	}

}
